package com.pctx.bibatracker.controller;

import com.pctx.bibacommon.result.Result;
import com.pctx.bibatracker.service.HistoryPositionService;
import com.pctx.bibatracker.service.NavigationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@CrossOrigin
@RestController
@RequestMapping("/historyPosition")
public class HistoryPositionController {
    @Autowired
    private HistoryPositionService historyPositionService;

    @Autowired
    private NavigationService navigationService;

    /**
     * 轨迹（百度坐标）
     *
     * @param deviceNo
     * @param startTime
     * @param stopTime
     * @return
     * @throws Exception
     */
    @RequestMapping("/getTrail")
    public Result getTrail(@RequestParam("deviceNo") String deviceNo, @RequestParam("startTime") String startTime, @RequestParam("stopTime") String stopTime) throws Exception {
        return historyPositionService.getTrail(deviceNo, startTime, stopTime);
    }

    /**
     * 前一天轨迹（百度坐标）
     *
     * @param deviceNo
     * @return
     * @throws Exception
     */
    @RequestMapping("/getTodayTrail")
    public Result getTodayTrail(String deviceNo) throws Exception {
        return historyPositionService.getTodayTrail(deviceNo);
    }

    /**
     * 导航（百度地图）
     *
     * @param address
     * @param deviceNo
     * @return
     * @throws Exception
     */
    @RequestMapping("/selectRoute")
    public Result selectRoute(String address, String deviceNo) throws Exception {
        return navigationService.selectRouteFromBaiDu(address, deviceNo);
    }

    /**
     * 导航（高德地图）
     *
     * @param address
     * @param deviceNo
     * @return
     * @throws Exception
     */
    @RequestMapping("/selectRouteFromGaoDe")
    public Result selectRouteFromGaoDe(String address, String deviceNo) throws Exception {
        return navigationService.selectRouteFromGaoDe(address, deviceNo);
    }

    /**
     * 轨迹（高德地图）
     *
     * @param deviceNo
     * @param startTime
     * @param stopTime
     * @return
     * @throws Exception
     */
    @RequestMapping("/getGaoDeTrail")
    public Result getGaoDeTrail(String deviceNo, String startTime, String stopTime) throws Exception {
        return historyPositionService.getGaoDeTrail(deviceNo, startTime, stopTime);
    }

    /**
     * 前一天轨迹（高德地图）
     *
     * @param deviceNo
     * @return
     * @throws Exception
     */
    @RequestMapping("/getGaoDeTodayTrail")
    public Result getGaoDeTodayTrail(String deviceNo) throws Exception {
        return historyPositionService.getGaoDeTodayTrail(deviceNo);
    }
}
